package cn.hy.today;

import datastruct.ListNode;


class Solution_82 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode dummyNode = new ListNode(-101, head);
        ListNode pre = dummyNode;
        ListNode cur = head;
        while (cur != null) {
            while (cur.next != null && cur.val == cur.next.val) {
                cur = cur.next;
            }
            if (pre.next == cur) {
                pre = cur;
            } else {
                pre.next = cur.next;
            }
            cur = cur.next;
        }
        return dummyNode.next;
    }
}